<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
   <!-- <link rel="stylesheet" href="../css/page-health-orderInfo.css" />
    <link rel="stylesheet" href="../plugins/elementui/index.css" />-->
    <script src="../plugins/jquery/dist/jquery.min.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../plugins/datapicker/datePicker.js"></script>
    <script src="../plugins/vue/vue.js"></script>
    <script src="../plugins/vue/axios-0.18.0.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../qrcode.min.js"></script>
    <script>

    </script>
</head>
<body >
<div id="qrCode" align="center" >http://www.itcast.cn</div>
<script>
    var pay_url = window.sessionStorage.getItem("pay_url")
    console.log("==================="+pay_url)
    let qrCode = new QRCode('qrCode',{
        text: 'url',
        width:200,
        height:200,
        correctLevel: QRCode.CorrectLevel.M
    });
    qrCode.makeCode(pay_url)


    // 每间隔五秒查询支付状态
    setInterval(function () {
        // 发送ajax请求
        $.get('/order/findState/'+window.sessionStorage.getItem('id'),function (resp) {
            if(resp.flag){
                // 支付成功了
                console.log("=============")
                window.location = "/pages/orderSuccess.html?id="+window.sessionStorage.getItem('id')
               // window.sessionStorage.removeItem('id')
                window.sessionStorage.removeItem('pay_url')
            }else{
                console.log("++++++++++++++++++++++")
            }
        })
      /*  $.get('/setmeal/findState/'+window.sessionStorage.getItem('id')).then(res=>{

            if(res.flag){
                console.log("=============")
                window.location = "/pages/pay.html?id="+window.sessionStorage.getItem('id')
                window.sessionStorage.removeItem('id')
                window.sessionStorage.removeItem('pay_url')
            }else{
                console.log("++++++++++++++++++++++")
            }
        })*/
    },5000);

    // 如果用户迟迟没有支付... 帅哥课上演示20秒
    setTimeout(function () {
        location.href='/pages/pay_fail.html';
    },60000);

</script>
</body>
</html>